/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.mintandleaf.webkits.data;

import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

/**
 * 
 * @author teguhh
 */
public class WebKitsDataModel {

    protected WebKitsDataMap map;

    public WebKitsDataModel(){

    }
    
    public <X> void set(String property,X value){
        if(map==null){
            map=new WebKitsDataMap();
        }
        map.put(property, value);
    }

    public <X> X get(String paramProperty){
        return map==null?null:(X)map.get(paramProperty);
    }

    public <X> X remove(String paramProperty){
       return map==null?null:(X)map.get(paramProperty);
    }

    public void setProperties(Map<String,Object> paramProperties){
        for(String property :paramProperties.keySet()){
            set(property,paramProperties.get(property));
        }
    }

    public Map<String,Object> getProperties(){
        HashMap<String,Object> newMap=new HashMap<String, Object>();
        if(map!=null){
            newMap.putAll(map.getTransientMap());
        }
        return newMap;
    }

    public Collection<String> getPropertyName(){
        Set<String> set=new HashSet<String>();
        if(map!=null)
            set.addAll(map.keySet());
        return set;
    }
}
